package com.lxn;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest(classes = SpringBootRabbitMq.class)
public class Send {
    @Autowired
    private RabbitTemplate rabbitTemplate;
    @Test
    public void testSend(){
        String message = "test rabbitmq";
        for(int i=0;i<10;i++){
            if(i%2==0){
                rabbitTemplate.convertAndSend(RabbitmqConfig.EXCHANGE_TOPICS_INFORM,"email.dfd",message);
            }else{
                rabbitTemplate.convertAndSend(RabbitmqConfig.EXCHANGE_TOPICS_INFORM,"sms.dfd",message);
            }
        }

    }

}
